#!/bin/sh

touch_dir(){
	mkdir result
	mkdir result/osd_result/
	mkdir result/encoder_result/
	mkdir result/audio_result/
	mkdir result/isp_result/
}

start_system_init_deinit(){
	echo "$1"
	./init_deinit/sample-System-init-deinit $1
}

start_isp(){
	echo "$1"
	./isp/sample-ISP $1
	mv /tmp/stream-isp* ./result/isp_result/
}

start_osd(){
	./osd/sample-Encoder-OSD
	mv /tmp/stream-osd* ./result/osd_result/
}

audio_init(){
	echo "enter audio modules"
	cp ./audio/res/webrtc_profile.ini /system/etc/
	cp ./audio/res/libaudioProcess.so /system/lib/
}

start_audio(){
	echo "audio $1"
	echo "start sample-Ai"
	./audio/sample-Ai $1 
	echo "start sample-Ao"
	./audio/sample-Ao $1
	echo "start sample-Ai-AEC"
	./audio/sample-Ai-AEC $1
	cp ./audio/res/ai_record.pcm ./result/audio_result/ai_record_$1.pcm
	cp ./audio/res/test_aec_record.pcm ./result/audio_result/test_aec_record_$1.pcm
}

start_encoder(){
	echo "enter encoder modules"
	echo "start sample-Encoder-changeRcParam-test"
	./encoder/sample-Encoder-changeRcParam-test
	echo "start sample-Encoder-changeRes-test"
	./encoder/sample-Encoder-changeRes-test
	echo "start sample-Encoder-h264-jpeg-test"
	./encoder/sample-Encoder-h264-jpeg-test
	mv /tmp/stream-encoder* ./result/encoder_result/
}

touch_dir
start_system_init_deinit 200
start_isp 200
start_osd
audio_init
start_audio 8000
start_audio 16000
start_audio 32000
start_encoder

cp /tmp/log.txt ./
